webpackJsonp([13],{

/***/ 0:
/***/ function(module, exports, __webpack_require__) {

	var url = __webpack_require__(10);
	var template = __webpack_require__(11);
	var main = __webpack_require__(13);
	var form = __webpack_require__(20);
	var module = __webpack_require__(21);

	//模板配置
	var tplArr = [];
	var confirmTpl = __webpack_require__(32);
	tplArr['confirm'] = template.compile(confirmTpl.replace(/^\s*|\s*$/g, ""));

	function Index() {
	    _this = this;
	    this.main = function () {
	        main.event(this, 'tap', 'i-click');
	        this.init();
	    };

	    this.getContent = function (getUrl, postUrl, addressUrl, ids, addrid) {
	        main.post(getUrl, { cart_id: ids }, function (rest) {
	            var ret = rest;
	            if (ret.code != 1) {
	                return false;
	            };
	            var dataPrice = {
	                tType: "price",
	                price: "0.00"
	            };
	            var dataAddress = {
	                tType: "address",
	                address: " ",
	                link: _this.jumpUrl + "?id=" + _this.ids
	            };
	            var dataOrder = {
	                tType: "orderList",
	                dataList: []
	            };
	            var p = 0;
	            for (var n in ret.data.cart) {
	                var _json = ret.data.cart[n];
	                var _data = {
	                    "cart_id": _json.cart_id,
	                    "id": _json.good_id,
	                    "title": _json.good_name,
	                    //"attr": [],
	                    "num": _json.good_sku,
	                    "spec": _json.colour + "," + _json.cup + "," + _json.size,
	                    "price": _json.shop_price,
	                    "quantity": _json.good_number,
	                    "image": _json.small_image,
	                    "n": _json.good_number,
	                    "store": ret.data.store_name
	                };
	                p += parseFloat(_json.shop_price) * parseFloat(_json.good_number);
	                dataOrder.dataList.push(_data);
	            }
	            var data = {
	                tType: "content",
	                price: tplArr['confirm'](dataPrice),
	                address: tplArr['confirm'](dataAddress),
	                orderList: module.ordersGoodsInfo(dataOrder.dataList),
	                click: "confirmOrder",
	                postUrl: postUrl,
	                cart: _this.ids
	            };
	            $(".content").html(tplArr['confirm'](data));
	            $(".price span").html("￥" + p);
	            _this.getAddress(addressUrl, addrid);
	        });
	    };
	    //获取地址
	    this.getAddress = function (addressUrl, addrid) {
	        var obj = {};
	        if (!!addrid) {
	            obj.address_id = addrid;
	        }
	        main.post(addressUrl, obj, function (rest) {
	            console.info(rest);
	            if (rest.code == 1) {
	                var ret = rest.data;
	                $("#address").html(ret.province_name + " " + ret.city_name + ret.district_name + ret.address + " " + ret.name + " " + ret.mobile);
	                $("#address_id").val(ret.address_id);
	            }
	        });
	    };

	    //提交订单
	    this.confirmOrder = function (ths) {
	        form.ajaxSubmit(".postForm", _this, ths);
	    };
	    this.formCallback = function (ret) {
	        console.info(ret);
	        if (ret.code == 1) {
	            var _url = _this.payUrl + "?order_id=" + ret.data.order_id + "&order_sn=" + ret.data.order_sn;
	            console.info(_url);
	            window.location.href = _url;
	        }
	    };

	    this.init = function () {
	        this.ids = main.GetQueryString("id");
	        this.addrid = main.GetQueryString("address_id");
	        this.getUrl = url.postConfirmOrder;
	        this.addressUrl = url.postSelectAddress;
	        this.postUrl = url.postPayOrder;
	        this.jumpUrl = "address";
	        this.payUrl = "http://protest1.woaap.com/pay/wechat";
	        this.getContent(this.getUrl, this.postUrl, this.addressUrl, this.ids, this.addrid);
	    };
	    return this.main();
	};

	var index = new Index();

/***/ },

/***/ 20:
/***/ function(module, exports, __webpack_require__) {

	var url = __webpack_require__(10);
	var template = __webpack_require__(12);
	var main = __webpack_require__(13);
	var modalTpl = __webpack_require__(18);

	//模板配置
	var tplArr = [];
	template.config('escape', false);
	tplArr['modal'] = template.compile(modalTpl.replace(/^\s*|\s*$/g, ""));

	//获取验证码
	function getCode(_dom, url, id) {
	  var _mobile = $('input[name="mobile"]').val();
	  var code = $('input[name="code"]').val();
	  if (_dom.text() != '获取验证码') {
	    return false;
	  }
	  if (_mobile == "") {
	    jsAlert('请输入手机号码');
	  } else if (/^1[3|4|5|7|8]\d{9}$/.test(_mobile) == false) {
	    jsAlert('手机号码格式有误');
	  } else {
	    _dom.text("校验中");
	    $.post(url, { "user_id": id, "mobile": _mobile }, function (json, textStatus) {
	      _json = json;
	      if (_json.code == 1) {
	        var tm = 60;
	        var tmr = setInterval(function () {
	          tm--;
	          if (tm > 0) {
	            _dom.text(tm + "秒");
	          } else {
	            _dom.text('获取验证码');
	            clearInterval(tmr);
	            tm = 60;
	            //_dom.attr('onclick','join.getCode()')
	          }
	        }, 1000);

	        jsAlert('验证码已发送');
	      } else if (_json.code == 2) {
	        jsAlert(_json.data);
	        _dom.text('获取验证码');
	      } else if (_json.code == 200) {
	        jsAlert(_json.data);
	        _dom.text('获取验证码');
	      }
	    }, 'json');
	  }
	}
	//弹窗
	function jsAlert(text, Fun) {
	  if (!Fun) {
	    Fun = 'm-click="modalAlertClose"';
	  }
	  var data = {
	    "type": "1",
	    "ico": 'warn',
	    "text": text,
	    "Callback": Fun
	  };
	  $('body').append(tplArr['modal'](data));
	}
	//表单数据整理
	// function ajaxSubmit_o(obj,module,but) {

	//   //var url = $(obj).attr("action") || window.location.href;
	//   var callback_name = $(obj).attr("callback");
	//   var url = $(obj).attr("action");
	//   var data = {};
	//   var ipts = {};
	//   $('input[name],textarea[name],select[name]',obj).each(function(item){
	//       var name = $(this).attr('name');
	//       var value = $(this).val();
	//       var ipt = $(this).attr('ipt');
	//       var isArray = /\[\]$/;
	//       if(isArray.test(name)){
	//           if(!data[name]){data[name]=[]}
	//           if(!ipts[name]){ipts[name]=[]}
	//           data[name].push(value);
	//           ipts[name].push(value,ipt);
	//       }else{
	//           data[name] = value;
	//           ipts[name] = [value,ipt];
	//       }
	//   });

	//   if(!yzForm(ipts)){return false;}
	//   but.attr('isSubmit','false').text('提交中...');
	//   $.ajax({
	//       url: url,
	//       type: "get",
	//       data: data,
	//       dataType: "json",
	//       success: function(ret){
	//           //if(ret.sms_success == "1"){
	//               //if(isNotEmpty(callback)) {
	//                 //_this.id = ret.success_id;
	//                 //jsConfirm('提示','请您确认所有填写的信息准确无误！',callback_name);
	//                 module[callback_name](ret);
	//               //}
	//           //}else if(ret.sms_success == "0"){
	//               //jsAlert("验证码错误");
	//           //}
	//       },
	//       error:function(ret){

	//       }
	//   });
	// }
	//表单数据整理
	function ajaxSubmit(obj, module, but) {
	  //console.info(module)
	  var but_val = but.html();
	  if (but_val == "提交中...") {
	    console.info("频次太快");
	    return false;
	  }
	  //var url = $(obj).attr("action") || window.location.href;
	  var callback_name = $(obj).attr("callback");
	  var url = $(obj).attr("action");
	  var formtype = $(obj).attr("f-type");
	  var data = {};
	  var ipts = {};
	  $('input[name],textarea[name],select[name]', obj).each(function (item) {
	    var name = $(this).attr('name');
	    var value = $(this).val();
	    var ipt = $(this).attr('ipt');
	    var isArray = /\[\]$/;
	    if (isArray.test(name)) {
	      if (!data[name]) {
	        data[name] = [];
	      }
	      if (!ipts[name]) {
	        ipts[name] = [];
	      }
	      data[name].push(value);
	      ipts[name].push(value, ipt);
	    } else {
	      data[name] = value;
	      ipts[name] = [value, ipt];
	    }
	  });

	  if ($("input[name='is_default']:checked").length == 1) {
	    data.is_default = 1;
	  } else {
	    data.is_default = 0;
	  }

	  if (!yzForm(ipts)) {
	    return false;
	  }
	  but.attr('isSubmit', 'false').html('提交中...');

	  //console.info(data)
	  data.openid = openid;
	  // $("body").html(data.serverId);
	  $.ajax({
	    url: url, //+"?openid_test=ojtKJjq93sF3dOoz4lA12MrxtcUk",
	    type: "post",
	    data: data,
	    dataType: "json",
	    success: function (ret) {
	      // console.info(ret)
	      //if(ret.sms_success == "1"){
	      //if(isNotEmpty(callback)) {
	      //_this.id = ret.success_id;
	      //jsConfirm('提示','请您确认所有填写的信息准确无误！',callback_name);
	      module[callback_name](ret);
	      but.html(but_val);
	      //}
	      //}else if(ret.sms_success == "0"){
	      //jsAlert("验证码错误");
	      //}
	    },
	    error: function (ret) {
	      but.html(but_val);
	      console.info(ret);
	    }
	  });
	}
	//方法验证
	function yzForm(data) {
	  var Ctrue = true;
	  var hour = $('select[name="sendplan_hour"]').val();
	  for (ipt in data) {
	    if (data[ipt][1] == 'true') {
	      continue;
	    }
	    switch (ipt) {

	      case 'name':
	        if (data[ipt][0] == "") {
	          isCtrue('请输入名字');return false;
	        }
	        break;

	      case 'mobile':
	        if (data[ipt][0] == "") {
	          isCtrue('请输入手机号码');return false;
	        } else if (/^1[3|4|5|7|8]\d{9}$/.test(data[ipt][0]) == false) {
	          isCtrue('手机号码格式有误');return false;
	        }
	        break;

	      case 'address':
	        if (data[ipt][0] == "") {
	          isCtrue('请输入详细地址');return false;
	        }
	        break;
	      case 'shipping_id':
	        if (data[ipt][0] == "") {
	          isCtrue('请选择物流');return false;
	        }
	        break;
	      case 'shipping_number':
	        if (data[ipt][0] == "") {
	          isCtrue('请填写物流单号');return false;
	        }
	        break;

	      // case 'is_default':
	      //    if(data[ipt][0]==""){isCtrue('请选择');return false;}
	      // break;
	    }
	  }
	  function isCtrue(text) {
	    Ctrue = false;
	    main.alert({
	      "title": "提示",
	      "content": text
	    });
	  };
	  return Ctrue;
	}

	exports.getCode = getCode;
	exports.jsAlert = jsAlert;
	exports.ajaxSubmit = ajaxSubmit;
	exports.yzForm = yzForm;

/***/ },

/***/ 32:
/***/ function(module, exports) {

	module.exports = "{{if tType== 'content'}}\n<form action=\"{{postUrl}}\" class=\"postForm\" callback=\"formCallback\">\n\t<input type=\"hidden\" name=\"cart_id\" value=\"{{cart}}\">\n\t<input type=\"hidden\" id=\"address_id\" name=\"address_id\" value=\"\">\t\n\t{{if !!address}}\n\t\t{{address}}\n\t{{/if}}\n\t{{if !!orderList}}\n\t\t{{orderList}}<!-- \n\t\t <a href=\"\" class=\"ui-btn pad-tb15 _btn\">返回购物车编辑</a> -->\n\t{{/if}}\n\t<div class=\"ui-form-item ui-border-b pad-t10 pad-b10\">\n        配送方式\n        <span class=\"fr\">商家配送</span>\n    </div>\n    <!-- <div class=\"arrlist ui-border-b pad-t10 pad-b10\"> \n\t    <div class=\"ui-form-item ui-form-item-link\">\n\t        <a href=\"\">\n\t        \t优惠券\n        \t\t<span class=\"fr pad-r20\">去凑单</span>\n        \t\t<span class=\"quan\">满99减5</span>\n\t        </a>\n\t    </div>   \n\t</div>  -->\n\t<div class=\"ui-form-item ui-form-item-textarea ui-border-b\">\n        <label>\n            订单备注\n        </label> \n        <textarea name=\"remarks\" rows=\"3\" placeholder=\"（限45字，请勿填写发票信息、配送方面信息）\"></textarea>\n    </div>\n\t{{if !!price}}\n\t\t{{price}}\n\t{{/if}}\t\n\t<div class=\"ui-btn-wrap pad-btn\">  \n     <a {{if link}}href=\"{{link}}\"{{/if}} {{if !!click}}i-click=\"{{click}}\"{{/if}} class=\"ui-btn-pink ui-btn-lg\">微信支付</a>\n    </div> \n</form>    \n{{/if}} \n{{if tType== 'price'}}\t\n\t<div class=\"price\">\n\t{{if !!price}}\n\t\t<h3 class=\"center ui-whitespace pad-t10\">总价：<span class=\"fz-18\">￥{{price}}</span></h3>\n\t{{/if}}\n\t</div>\n{{/if}}\n{{if tType== \"address\"}}\n<p class=\"ui-whitespace pad-t10\">配送地址</p>\n<div class=\"arrlist confirm-address ui-border-b\"> \n    <div class=\"ui-form-item ui-form-item-link ui-border-b\">\n        <a href=\"{{link}}\" {{if click}}i-click=\"{{click}}\"{{/if}}>\n        [<span class=\"pink\">默认</span>] <span id=\"address\">{{address}}</span>\n        </a>\n    </div>   \n</div>\n{{/if}}"

/***/ }

});